package action;


import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
import java.util.List;

import org.apache.struts2.ServletActionContext;
import org.hibernate.Session;

import po.*;


import bean.EmailBean;
import bo.HibernateSessionFactory;

import com.opensymphony.xwork2.ActionSupport;

public class EmailTestXiu extends ActionSupport{
	
	private String accepter;
	private String sender;
	private String theme;
	private String contents;
	private int id;




	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getAccepter() {
		return accepter;
	}

	public void setAccepter(String accepter) {
		this.accepter = accepter;
	}

	public String getSender() {
		return sender;
	}

	public void setSender(String sender) {
		this.sender = sender;
	}

	public String getTheme() {
		return theme;
	}

	public void setTheme(String theme) {
		this.theme = theme;
	}

	public String getContents() {
		return contents;
	}

	public void setContents(String contents) {
		this.contents = contents;
	}

	public String execute(){
		
		
		Date d = new Date();  				//获得当前日期
		SimpleDateFormat tempDate = new SimpleDateFormat("yyyy-MM-dd"); //设定日期格式
		String date = tempDate.format(d);
		
		Email e = new EmailDAO().findById(id);
		e.setAccepter(accepter);
		e.setContent(contents);
		e.setSender(sender);
		e.setTheme(theme);
		e.setSendtime(date);
		Session session = HibernateSessionFactory.getSession();
		session.save(e);
		session.beginTransaction().commit();
		
		return "save";
		
			
	}


}
